package lib.self.util.view;

import android.graphics.Paint;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.widget.TextView;

/**
 * description: TextView工具类
 * author: Steven Xiao
 * date: 2017/4/26
 */
public class TextViewUtil {
    /**
     * 添加下划线
     */
    public static void setTextViewUnderLine(TextView textView) {
        textView.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG | Paint.UNDERLINE_TEXT_FLAG);
    }

    /**
     * 恢复原始状态
     */
    public static void resetTextViewFlag(TextView textView) {
        textView.getPaint().setFlags(0 | Paint.DEV_KERN_TEXT_FLAG);
    }

    /**
     * 限制输入字数
     */
    public static void limitInputCount(TextView textView, int max) {
        textView.setFilters(new InputFilter[]{new LengthFilter(max)});
    }
}
